/*
 * @Author: 缄默
 * @Date: 2021-12-11 15:20:54
 * @LastEditors: 缄默
 * @LastEditTime: 2021-12-11 15:28:19
 */

#include <iostream>

using namespace std;

class Reciever {
public:
    void Action() {
        cout << "Reciver::Action..." << endl;
    }
};

class Command {
public:
    virtual ~Command() { }
    virtual void Excute() = 0;
};

class ConcreteCommand : public Command {
private:
    Reciever* _rev;
public:
    ConcreteCommand(Reciever* rev) {
        _rev = rev;
    }

    void Excute() {
        _rev->Action();
    }
};

class Invoker {
private:
    Command* _cmd;
public:
    Invoker(Command* cmd) {
        _cmd = cmd;
    }
    void Invoke() {
        _cmd->Excute();
    }
};

int main() {
    Reciever* rev = new Reciever();
    Command* cmd = new ConcreteCommand(rev);
    Invoker* inv = new Invoker(cmd);
    inv->Invoke();

    delete rev;
    delete cmd;
    delete inv;

    return 0;
}
